package com.shanzmoo.db.sys.entity.dto;

import com.alibaba.fastjson.JSON;
import com.shanzmoo.db.sys.entity.MenuEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

/**
 * 菜单保存对象
 * @author: Gzhao 2020/11/10
 */
@Data
@ApiModel("菜单新增对象")
public class MenuSaveDto {

    @NotNull(message = "父级菜单id不允许为空")
    @ApiModelProperty("父级菜单id" )
    private Integer parentId;

    @NotNull(message = "菜单类型不允许为空")
    @ApiModelProperty("菜单类型：0-头部目录，1-左侧一级菜单，2-左侧二级菜单，3-按钮" )
    private Integer menuType;

    @ApiModelProperty("菜单图标" )
    private String menuIco;

    @NotBlank(message = "菜单名称不允许为空")
    @ApiModelProperty("菜单名称" )
    private String menuName;

    @ApiModelProperty("前端路由地址：类型为0,1时必填" )
    private String routerUrl;

    @ApiModelProperty("前端组件路径：类型为1时必填" )
    private String componentPath;

    @ApiModelProperty("权限标识：类型为1，2时必填" )
    private String perms;

    @ApiModelProperty("排序号" )
    private Integer menuIndex;

    public static MenuEntity converted(MenuSaveDto saveDto) {
        return JSON.parseObject(JSON.toJSONString(saveDto), MenuEntity.class);
    }
}
